#ifndef __TOUCHSCREEN_H
#define __TOUCHSCREEN_H

#ifdef __cplusplus
 extern "C" {
#endif
	 
#include "System.h"
#include "Board.h"

#if ENABLE_TOUCH
#include "SysFifo.h"

/* Set Multi-touch as supported */
#if !defined(TS_MULTI_TOUCH_SUPPORTED)
#define TS_MULTI_TOUCH_SUPPORTED        0
#endif /* TS_MONO_TOUCH_SUPPORTED */

#define Touch_MAX          32

#define Touch_RST_HI()		HAL_GPIO_WritePin(TP_RST_PORT, TP_RST_PIN, GPIO_PIN_SET)
#define Touch_RST_LOW()		HAL_GPIO_WritePin(TP_RST_PORT, TP_RST_PIN, GPIO_PIN_RESET)
	 
typedef struct{
	uint16_t 	TouchID;
    uint8_t 	TouchVer;
}TouchInfo;
typedef struct{
	uint8_t		id;
	uint8_t 	status;
	uint16_t 	x;
	uint16_t 	y;
}Coord;
typedef struct{
    Fifo_T	fifo;
	Coord 	data[Touch_MAX];
}TouchData;

typedef struct{
	TouchInfo	*info;
    void 		(*init)(void);
	void 		(*rest)(void);
	uint8_t 	(*getData)(Coord *);
}TouchDev;

extern TouchDev	g_touchDev;

void 	TouchScreen_REST(void);
void 	TouchScreen_Init(void);
uint8_t TouchScreen_Read(void);

void 	Touch_DataInit(void);
uint8_t Touch_InserData(Coord _coord);
uint8_t Touch_GetData(Coord *_coord);
	
#endif
	 
#ifdef __cplusplus
}
#endif
#endif
